Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deck: used fisher-yates algorithm to shuffle deck array #13

Closed

Conversation

sethdivyansh
Copy link
Contributor

Fixes #2

used Fisher-Yates shuffle algorithm to shuffle the deck array.

Self-review checklist
  • Self reviewed the changes for clarity and maintainability (variable names, code reuse, readability, etc.).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.
  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

@@ -66,5 +66,9 @@ function makeCard(type: CardType, color: CardColor, value: CardValue): UNOCard {
*/
function shuffle(deck: Array<any>) {
//todo: Implement a generic shuffling algorithm
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this comment

@@ -66,5 +66,9 @@ function makeCard(type: CardType, color: CardColor, value: CardValue): UNOCard {
*/
function shuffle(deck: Array<any>) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any would cause eslint errors.

@kuv2707
Copy link
Collaborator

kuv2707 commented May 31, 2024

#16 is preferred for this issue, as they had taken it earlier (but had to close the PR).

This PR is proper for integration, so we can fall back to it if no progress is made in #16 .

@sethdivyansh sethdivyansh changed the title used fisher-yates algo to shuffle deck array deck: used fisher-yates algorithm to shuffle deck array May 31, 2024
- added black as a color in `CardColor` in `types.d.ts`
- separated the values of special cards and wild cards into two arrays named specialValues and wildCardValues, respectively.
- Iterates over each color in the colors array.
  For each color:
  * Iterates over each number value (0 to 9) in the numValues array and adds two cards of that color for each number, except for '0' where only one card is added.
  * Iterates over each special value in the specialValues array and adds two cards of that color for each special value.
  * If the color is 'black', iterates over each wild card value in the wildCardValue array and adds four cards of that color for each wild card value.
@sethdivyansh sethdivyansh deleted the fix/issue-#2 branch May 31, 2024 18:12
@sethdivyansh
Copy link
Contributor Author

I accidentally deleted the fix/issue-#2 branch, which caused #13 to be closed. I've now opened a new PR #31; please review this one instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement card shuffling logic
2 participants